<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"/>
<%@ include file="/commons/jsp/taglibs.jsp"%>
<%@taglib prefix="frame" uri="http://www.framework.com/taglib"%>

<html>
  <head>
        <link href="${ctx}/commons/css/style.css" rel="stylesheet" type="text/css"/>
     	<link rel="stylesheet" type="text/css" href="${ctx}/commons/themes/default/easyui.css"></link>
     	<link rel="stylesheet" type="text/css" href="${ctx}/commons/themes/icon.css"></link>
     	<!-- jqueryUI JS文件的引入 -->
	    <script type="text/javascript" src="${ctx}/commons/js/jquery-1.8.0.min.js"></script>
	    <script type="text/javascript" src="${ctx}/commons/js/jquery.easyui.min.js"></script>
	    <script type="text/javascript" src="${ctx}/commons/js/easyui-extends-validate.js"></script>
	    <!-- jqueryUI国际化 -->
	    <script type="text/javascript" src="${ctx}/commons/js/easyui-lang-zh_CN.js"></script>
	    <!-- 开发使用的公用js方法 -->
	    <script type="text/javascript" src="${ctx}/commons/js/common.js"></script>
	    <!-- 开发国际化的引用，主要完成后台信息在前台提示的国际化，一定要放在最后 -->
	    <script type="text/javascript">var ctx = '${ctx}';var actionExt = "action";var i18n = new Object();</script>
	    <script src="${ctx}/commons/js/i18n/message_zh_CN.js" type="text/javascript"></script>
 </head>
    <body>
      <div class="easyui-layout" style="width:100%;height:100%;">
      <form id="myform">
		       <div data-options="region:'north',border:false" style="padding: 4px;height: 50px;overflow: hidden;"id="banner">
		    		<div class="easyui-panel" data-options="fit:true,border:true" >
					<div class="queryContent" >			
						<table class="queryTable" >
							<tbody>
								<tr>
									<th width="50%">按时间检索</th>
									<td width="10%">
		                              <input id="startTime" class="easyui-datebox" type="text" name="startTime"  data-options="validType:['dateTimeLessCompare[\'endTime\']']" maxlength="20" style="width:120px"/>-<input id="endTime" class="easyui-datebox" type="text"  data-options="validType:['dateTimeMoreCompare[\'startTime\']']" name="endTime" maxlength="20" style="width:120px"/>
									  <select class="easyui-combobox" id="readFlag" name="readFlag" style="width:150px;"> 
									    <option value="" >--请选择类型--</option>  
									    <option value="0">未读</option>   
									    <option value="1">已读</option>   
								      </select>
								<td align="right" width="10%"><a href="javascript:void(0);" class="easyui-linkbutton" onclick="searchMessage();"  plain="true">查询</a>
								 
								<a href="javascript:void(0);" class="easyui-linkbutton" id="resetSearch" onclick="clearSearch();" plain="true">清空</a></td>
								</tr>
							</tbody>
						</table>				
					</div>
				  </div>
		        </div>
		       <div data-options="region:'center'">
		           <table id="mydialog" data-options="toolbar:'#toolbar',fit:true,fitColumns:true"></table>
		       </div>
		  </div>
	  </form>
	         <input type="hidden" name="projectId" value="${projectId}" id="projectId"/> 	       
		        
		         <div id="mydialog2"></div>            
	        
       </body>
	    <script type="text/javascript">
	     var projectId=$("#projectId").val();
	     var professorId
	     var arr
	    $(function(){   
	         $('#mydialog').datagrid({
	                     idField:'id',
                         url:'${ctx}/framework/message/getMessageList',      
	                     fitColumns:true,//自动填充宽度
	                     striped:true,//隔行变色
	                     loadMsg:"数据正在加载中.....",
	                     rownumbers:true,//显示序号
	                    // singleSelect:true,
	                     pagination:true,	
	                     nowrap:false,                    
	                     pageSize:5,
	                     pageList:[20,40,60,80],
	                     columns:[[   
	                     { field:'ck',checkbox:true }, 
				       //{field:'title',title:'标题',width:150,align:'center'}, 
				         {field:'contents',title:'内容',width:1000,align:'center'}, 
				     //  {field:'warnType',title:'类型',width:230,align:'center'},
				         {field:'readerName',title:'读取者名',width:150,align:'center'},     
				        // {field:'projectId',title:'项目Id',width:150,align:'center'},     
				      // {field:'warringId',title:'预警Id',width:150,align:'center'},     
				         {field:'createTime',title:'创建时间',width:150,align:'center'},
				         {field:'readFlag',title:'读取标志',width:150,align:'center',formatter:formatFlag},
				         {field:'operate',title:'操作', align:'center',width:150,formatter:formatOper}		
			            ]],
			            toolbar:[
					                {text:'批量标记已读',iconCls:'icon-add',handler:function(){  			                    
		                                     readed();
		                                }  
		                            }
					                <c:if test="${isShowExportBtn}">
					                ,{text:'导出项目',iconCls:'icon-export',handler:function(){  			                    
	                                     exportProjects();
	                                	}
	                            		}
					                </c:if>
		                           
		                       ]     
			        });
		 });
	     
	       //操作
			function formatOper(val, row, index) {
				if (row.readFlag == 0 ) {
					return '<a href="#" onclick="readed(\'' + row.id+ '\',\'read\')">标记已读</a>';
				}else
				{
					return ""
				}

			}
			
	       //读取标记
			function formatFlag(val, row, index) {
				if (row.readFlag == 0) {
					return '<font color="green">未读</font>';
				} else if (row.readFlag == 1) {
					return '<font color="blue">已读</font>';
				}
			}
       
	       
	       //标记信息已读
	        function readed(id){
	        	var arr =$('#mydialog').datagrid('getSelections');
		    	  if(arr.length <1){
					     $.messager.show({
					        title:"提示信息",
					        msg:"请选择一条记录进行修改!"				        
					     });
					     return false;
					   }
		    	    var ids = '';
					for(var i =0 ;i<arr.length;i++){
						ids += arr[i].id + ',' ;
					}
					ids = ids.substring(0 , ids.length-1);
					$.ajax({
						type:'post',
						url:'${ctx}/framework/message/readed',
						data:{ids:ids},
						success:function(data){
							  $('#mydialog').datagrid('reload');
						}
					});
	        }
	       
	       
	       //查询
	       function searchMessage(){
	    	  $('#mydialog').datagrid('load', {    
	    		    startTime:$("#startTime").datebox('getValue'),    
	    		    endTime: $("#endTime").datebox('getValue'),
	    		    flag:$("#readFlag").combobox('getValue')
	    		}); 

	       }
	       
	       //清空搜索
	       function clearSearch(){
	    	 $("#myform").find(".easyui-combobox").each(function(){
	   			$(this).combobox('setValue',"");
	   		});
	   		$("#myform").find(".easyui-datebox").each(function(){
	   			$(this).datebox("setValue","");
	   		});
	   		$("#myform").find(".easyui-datetimebox").each(function(){
	   			$(this).datebox("setValue","");
	   		});
	       }
		 
	       /**
	       *导出项目
	       */
	       function exportProjects(){
	    	   top.$('#firstLevelDialog').dialog({    
				    title:"导出项目",  
				    iconCls:'icon-view',
				    width: 1000,    
				    height: 630,    
				    closed: false,    
				    inline : true,
				    cache: false,    
				    href: "${ctx}/business/report/messageProjectReport",
				    modal: true,
					extractor : function(data){
						if($.trim(data) == "unLogin"){
							var msn = ''||i18n[''];
							msn = msn||i18n[data];
							if(msn != undefined){
								top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
								return '';
							}
						}
						return data;
					},
				    buttons : [{
							text:"取消",
							iconCls:'icon-cancel',
							handler:function(){
								top.$('#firstLevelDialog').dialog('close');
							}}]
				});
				top.$('#firstLevelDialog').dialog("center");
	       }
		
       </script>
</html>
                 
   
  
